//
//  AYMHomeBottomBelowView.m
//  QuickCure
//
//  Created by 徐绩 on 16/5/4.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "AYMHomeBottomBelowView.h"
#import "AYMHomeMenuBtn.h"


@implementation AYMHomeBottomBelowView

-(instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    
    self.distribution = UIStackViewDistributionFillEqually;
   UIButton *xy = [self addChildbtnImageName:@"xy" title:@"血液科"];
   UIButton *gt = [self addChildbtnImageName:@"gt" title:@"骨科"];
   UIButton *gy = [self addChildbtnImageName:@"gy" title:@"公益"];
    xy.tag = 1;
    gt.tag = 1;
    gy.tag = 2;
    
  
}

-(UIButton *)addChildbtnImageName:(NSString *)imageName title:(NSString *)btnTitle{
    
    AYMHomeMenuBtn *btn = [[AYMHomeMenuBtn alloc]init];
    
    [btn addTarget:self action:@selector(didBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setTitle:btnTitle forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self addArrangedSubview:btn];
    return btn;
    
}

//点击首页底部6个按钮的方法

-(void)didBtn:(UIButton *)button{
    
    Log(@"%ld",(long)button.tag);
    
    if (button.tag == 1) {
        
        NSDictionary *dict = @{@"tet":button.titleLabel.text};
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"didButton" object:nil userInfo:dict];

        
    }else{
        
         [[NSNotificationCenter defaultCenter] postNotificationName:@"didLastButton" object:button];
        
    }
    
    
    
}


@end
